package com.kjlink.internal.workreport.user.service;

import cn.xuqiudong.common.base.lookup.Lookup;
import cn.xuqiudong.common.base.model.PageInfo;
import cn.xuqiudong.common.base.service.BaseService;
import cn.xuqiudong.common.base.vo.Select2VO;
import com.kjlink.internal.workreport.user.lookup.UserListLookup;
import com.kjlink.internal.workreport.user.mapper.UserMapper;
import com.kjlink.internal.workreport.user.model.User;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 功能: :用户,来自oa Service
 *
 * @author Vic.xu
 * @since 2024-04-29 13:38
 */
@Service
public class UserService extends BaseService<UserMapper, User> {

    @Override
    protected boolean hasAttachment() {
        return false;
    }

    public User getByUserCode(String usercode) {
        return mapper.getByUserCode(usercode);
    }

    @Override
    public PageInfo<User> page(Lookup lookup) {
        startPage(lookup.getPage(), lookup.getSize());
        List<User> dataList = mapper.list(lookup);
        return PageInfo.instance(dataList, lookup);
    }

    /**
     * 查询项目下的用户
     *
     * @param projectId projectId
     * @return
     */
    public List<User> findUsersByProjectId(Integer projectId) {
        return mapper.findUsersByProjectId(projectId);
    }

    /**
     * 供项目选择的人员列表:  尚未被选择的其他人员
     *
     * @param lookup 包含 projectId
     */
    public List<User> userList(UserListLookup lookup) {
        return mapper.userList(lookup);
    }

    public List<Select2VO> findByGroupId(Integer groupId) {
        return mapper.findByGroupId(groupId);
    }
    public List<User> findUserByGroupIds(List<Integer> groupIds){
        return mapper.findUserByGroupIds(groupIds);
    }

    public List<Select2VO> all() {
        return mapper.all();
    }
    public List<Select2VO> managerUsers() {
        return mapper.managerUsers();
    }

    /**
     * 根据组id查询用户数量
     *
     * @param groupId
     */
    public int checkUserNumberByGroupId(int groupId) {
        return mapper.checkUserNumberByGroupId(groupId);
    }
}
